package com.kolon.business.mngr.service.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.kolon.business.mngr.service.dao.ServiceDao;
import com.kolon.framework.constant.Constant;
import com.kolon.framework.interfaces.SimpleController;

@Controller("com.kolon.business.mngr.service.controller.DeptAppsDeleteController")
public class DeptAppsDeleteController implements SimpleController {

	@Resource(name="com.kolon.business.mngr.service.dao.ServiceDaoImpl")
	private ServiceDao serviceDao;
	
	@SuppressWarnings("rawtypes")
	@RequestMapping(value="/business/mngr/service/deptAppsDelete.do")
	public ModelAndView controller(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
		
		Map<String, String> map = new HashMap<String, String>();
		// 회원 세션 정보
		HttpSession httpSession = request.getSession();
		Map userMap = (Map)httpSession.getAttribute(Constant.SESSION_MNGR_INFO);
		map.put("mdfyId", (String)userMap.get("MNGR_ID"));
		// 파라미터
		String servNo = request.getParameter("servNo");
		map.put("servTeamNo", request.getParameter("servTeamNo"));
		map.put("servNo", servNo);
		map.put("useYn", "N");
		// 삭제
		serviceDao.updateTeamUseYn(map);
		//serviceDao.deleteServTeam(map);
		// 서비스 수정날짜 변경
		serviceDao.updateMdfyDttm(map);
		// 리턴
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("redirect:/business/mngr/service/deptApps.do");
		modelAndView.addObject("pop", "Y");
		modelAndView.addObject("servNo", servNo);
		return modelAndView;
	}
}
